using System;
using System.Collections.Generic;
using System.Text;

namespace Acms.AcmsControls
{
    public class TextContentControlEdit : BaseContentControlEdit
    {
        private System.Web.UI.WebControls.TextBox txtEdit;
        private System.Web.UI.WebControls.Literal litDisplay;

        protected override void CreateDisplayControls(System.Web.UI.WebControls.PlaceHolder placholder)
        {
            litDisplay = new System.Web.UI.WebControls.Literal();
            litDisplay.ID = "litDisplay";
            litDisplay.EnableViewState = true;
            placholder.Controls.Add(litDisplay);
        }

        protected override void CreateEditControls(System.Web.UI.WebControls.PlaceHolder placholder)
        {
            txtEdit = new System.Web.UI.WebControls.TextBox();
            txtEdit.ID = "txtEdit";
            placholder.Controls.Add(txtEdit);
        }

        private TextContentControlProperties properties;
        public TextContentControlProperties Properties
        {
            get 
            {
                if (properties == null)
                {
                    properties = new TextContentControlProperties();
                }
                return properties; 
            }
        }
	

        protected override BaseContentControlProperties GetProperties()
        {
            return Properties;
        }

        protected override void SetProperties(BaseContentControlProperties properties)
        {
            this.properties = properties as TextContentControlProperties;
        }

        protected override void DataBindChildren()
        {
            txtEdit.Text = Properties.Text;
            litDisplay.Text = Properties.Text;
            base.DataBindChildren();
        }

        protected override void SaveToProperties()
        {
            Properties.Text = txtEdit.Text;
        }

        protected override void DeleteFromProperties()
        {
        }
    }
}
